import time

from data_push.data_push import DataPush
from db_utils import MysqlEngine
from utils import *
while True:
    time.sleep(5)
    now = datetime.now()
    print(now)
    if now.hour == 13 and now.minute == 0:
        conn = MysqlEngine(MYSQL_USER_NAME, MYSQL_PASSWORD, MYSQL_HOST)
        data_push = DataPush(conn)
        data_push.push_tiktok_new_anchor_task(WeChat_ROBOT_Main)
        time.sleep(5)
        data_push.push_tiktok_basic_task(WeChat_ROBOT_Main)
        time.sleep(5)
        data_push.push_tiktok_process_active_task(WeChat_ROBOT_Main)
        time.sleep(5)
        data_push.push_tiktok_process_video_task(WeChat_ROBOT_Main)
        time.sleep(5)
        data_push.push_tiktok_coin_add(WeChat_ROBOT_Main)
        time.sleep(60)
    if now.hour == 20 and now.minute == 30:
        conn = MysqlEngine(MYSQL_USER_NAME, MYSQL_PASSWORD, MYSQL_HOST)
        data_push = DataPush(conn)
        data_push.push_tiktok_new_anchor_add(WeChat_ROBOT_Main)
        time.sleep(60)
    # if now.hour >= 8 and now.hour < 21 and now.hour % 1 == 0 and now.minute == 0:
    if (now.hour == 8 or now.hour == 12 or now.hour == 19) and now.minute == 45:
        conn = MysqlEngine(MYSQL_USER_NAME, MYSQL_PASSWORD, MYSQL_HOST)
        data_push = DataPush(conn)
        data_push.push_log(WeChat_ROBOT_TEST)
        time.sleep(60)
